import BaseUtil from '@/BaseUtil';
import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import EffectCommon from 'code/Core/Common/EffectCommon';
import MovementCommon from 'code/Core/Common/MovementCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 盲目
 **/
export default class BossSpell_Mangmu extends AbilityBase {
    static instance: BossSpell_Mangmu;
    buffType: AppBuffType = {
        id: 'buff_BossSpell_Mangmu',
        art: this.art,
        name: this.abilityName,
        ubertip: this.ubertip,
        attribute: {
            命中: -0.15,
        },
        stackCountMax: 3,
        dur: 5,
        interval: 1,
        onInterval: this.onBuffInterval.bind(this),
        isDebuff: true,
    };
    onBuffInterval(buff: Buff) {
        let dmg = 400 * buff.stackCount;
        DamageSystemInstance.applyDarkDamage(buff.getParent(), buff.getCaster(), dmg, null, true);
    }
    constructor(id: string = 'Mzw5') {
        super(id);
        BossSpell_Mangmu.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BossAbilityManagerInstance.text('盲目', source);
        BaseUtil.runLater(1, () => {
            this.effect(source);
            source = null;
        });
    }
    effect(source: unit) {
        let es = SelectUtil.getEnemyUnitsInRange(source, 900);
        for (let e of es) {
            MovementCommon.定点投射物({
                missile: 'Abilities\\Weapons\\CryptFiendMissile\\CryptFiendMissile.mdl',
                tarX: GetUnitX(e),
                tarY: GetUnitY(e),
                speed: 500,
                radian: 0.5,
                caster: source,
                onReachTarget: this.onReach.bind(this),
            });
        }
    }
    onReach(p: 定点投射物参数) {
        EffectCommon.addEffectAndDeleyRemove('古流\\sem_gu_liu.mdx', p.curX, p.curY, 5);
        BaseUtil.onTimer(1, (c) => {
            let es = SelectUtil.getEnemyUnitsInRange(p.caster, 125, p.curX, p.curY);
            for (let e of es) {
                BuffUtil.addBuff(e, this.buffType.id, p.caster);
            }
            return c < 5;
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
